In [1]:
%matplotlib inline

Image as complex edges process and display:

In [2]:
import os
import sys
import time
import hashlib
import inspect
import traceback
import json
from collections import OrderedDict

import numpy as np
import pandas as pd
import yaml

from PIL import Image
from PIL import ImageFile
from PIL import ImageOps
from PIL.ImageStat import Stat
from PIL import TiffImagePlugin as tip

import matplotlib as mpl
from matplotlib import cm
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.pyplot as pyplot

fmf_src = '../../FlyingMachineFractal/src/'
sys.path.insert(0, fmf_src)
from graphic_utility import *

sys.path.insert(0, '../src')
from complex_edges import *
In [3]:
"""
            find some images
"""
im_type_list = ['.tif', '.tiff']
im_dir = '/Users/mojo/pictures/Explorations/tmpProcessTank/'
f_list = []
for maybef in os.listdir(im_dir):
    _, f_ext = os.path.splitext(maybef)
    maybefull = os.path.join(im_dir, maybef)
    if os.path.isfile(maybefull) and f_ext in im_type_list:
        f_list.append((maybef, maybefull))
        
im_dict = OrderedDict(f_list)

enu_dict = {k: v for k, v in enumerate(im_dict.items())}
# for kn in range(len(enu_dict)):
#     print('%3i'%(kn), os.path.isfile(enu_dict[kn][1]), '\t', enu_dict[kn][0])
In [4]:
""" Bombers:
    [56, 12, 17, 24, 26, 32, 34, 51, 56]
    
    Besties:
    [9, 10, 14, 16, 22, 23, 25, 33, 35, 39, 40, 41, 42, 46, 49, 50, 
     52, 54, 57, 58, 59, 68, 69, 70, 74, 75, 77, 78, 79]
    
    Maybes:
    [55]
"""
im_no = 9
im = Image.open(enu_dict[im_no][1])
print(enu_dict[im_no][0], im.size)
display(im)
AMZ.tif (1280, 800)
In [5]:
im_gray = im.convert('L')
im_gray_array = np.array(im_gray)

print(im_gray.size)
print('original as grayscale')
display(im_gray)

n = 1
Z = im_to_Z(im_gray_array, n)
display(complex_magnitude_image(Z))

im_inv = ImageOps.invert(complex_mat_to_im(Z))
display(im_inv)
(1280, 800)
original as grayscale

Generated Images as complex edges:

In [ ]:
destination_dir = '../images'
file_type_ext = '.png'
good_edge_images = [10, 14, 23, 40, 41, 46, 52, 54, 55, 57, 68, 70, 75]

n = 1
for b_name in good_edge_images:
    t0 = time.time()
    im = Image.open(enu_dict[b_name][1])
    im_gray = im.convert('L')
    im_gray_array = np.array(im_gray)

    Z = im_to_Z(im_gray_array, n)
    im_inv = ImageOps.invert(complex_mat_to_im(Z))
    src_file_name = enu_dict[b_name][0]
    s_f_name_root, f_ext = os.path.splitext(src_file_name)
    out_file_name = 'z_conv_' + s_f_name_root + file_type_ext
    out_file_name = os.path.join(destination_dir, out_file_name)
    im_inv.save(out_file_name)
    print('\n\ntt: %0.3f s'%(time.time() - t0), b_name, src_file_name, im.size)
    display(im_inv)

tt: 2.567 s 10 RedWing.11.15.01_10.20.2008.tif (1800, 1800)

tt: 0.747 s 14 JZ3pCAKstar.tif (1280, 800)

tt: 0.223 s 23 Uno.tif (640, 400)

tt: 0.239 s 40 Tre.tif (640, 400)

tt: 0.207 s 41 Dos.tif (640, 400)

tt: 0.860 s 46 Rad_Hall3272011130324.tif (1280, 800)

tt: 0.138 s 52 AETXerch.9.55.20_7.17.2010.tif (400, 400)

tt: 0.503 s 54 OneWhack.19.17.25_8.07.2008.tif (800, 800)

tt: 10.538 s 55 AAnglBnSqr16x20.18.03.22_2.13.2009.tif (3571, 3571)

tt: 3.674 s 57 nuttin.tif (2560, 1600)

tt: 0.249 s 68 lamber.8.33.23_1.22.2009.tif (640, 400)

tt: 0.207 s 70 Quatrow.tif (640, 400)
In [10]:
destination_dir = '../images'
os.listdir(destination_dir)
Out[10]:
['01_RR_2257_10frame.tiff',
 '.DS_Store',
 'adecPwrAFxLFQNTAAAFD.png',
 'helloKeras.png',
 'z2dazexp.png',
 'BackPropOverview.png',
 'nn2input.ai',
 'LogRegDerivati.png',
 'adecPwrAFxLFQNTAAADW.png',
 'decPwrAFxLFQNTAABCL.png']
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: